﻿@using ASC.Resources;
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>asc FP Server</title>


    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/normalize.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/ui-lightness/jquery-ui-1.8.23.custom.css")" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery-1.8.0.min.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.23.custom.min.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>

        <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
     <script src="@Url.Content("~/Scripts/jquery.maskedinput-1.3.min.js")" type="text/javascript"></script>


</head>
<body>
<script>
    function refreshTree() {
        $('#treeTD').load("@Url.Action("Index", "Tree")", function () {
            
        });
    }

    function nodeAction(action, obj)
    {
        var id = $(obj[0]).val();
        var type;
        if(obj.hasClass("channel"))
        {
            type = 1;
        }else if(obj.hasClass("module"))
        {
            type = 2;
        }
        
        switch(action)
        {
            case 'add' :
            {
                if(type == 1)
                {
                    window.location = "@Url.Action("Add", "Channel")";
                }

                if(type == 2)
                {
                    window.location = "@Url.Action("Add", "Module")";
                }
            }break;

            case 'edit' :
            {
                if(type == 1)
                {
                    window.location = "@Url.Action("Edit", "Channel", new{id=""})"+ '/' + id;
                }

                if(type == 2)
                {
                    window.location = "@Url.Action("Edit", "Module", new { id = "" })"+ '/' + id;
                }
            }break;

            case 'delete' :
            {
              
                var currentId = '@Url.RequestContext.RouteData.Values["id"]';
                if(confirm("Delete object?"))
                {

                    $.ajax({
                      type: 'POST',
                      url: type == 1 ? "@Url.Action("Delete", "Channel")" : "@Url.Action("Delete", "Module")",
                      data: {id: id},
                      success: function(){ 
                        if(id == currentId)
                            window.location = '@Url.Action("Index", "Home")';
                        refreshTree();
                      },
                      dataType: 'json'
                    });
                }
            }break;
        }
        
    }
</script>
    <div id="container" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
        <div style="width: 100%; text-align: center">
            <h1>@Global.SiteName</h1>
        </div>
        <header id="mainHeader">
           
            @Html.Partial("_Menu")
        </header>
        <div class="clear">
        </div>
        <div id="content">
            <table style="width: 100%">
                <tr>
                    <td id="treeTD" style="width: 230px; vertical-align: top">
                        @Html.Action("Index", "Tree")
                    </td>
                    <td style="width: 600px; vertical-align: top">@RenderBody()
                    </td>
                </tr>
            </table>
        </div>
        <footer id="footer">     
        </footer>
    </div>
</body>
</html>
